package com.starnet.studentmanagement.vo;

import lombok.Data;

@Data
public class Result {
    //状态码
    private Integer code;
    //提示消息
    private String msg;
    //数据部分
    private Object data;


    public Result(Integer code, String msg, Object data) {
        this.code = code;
        this.msg = msg;
        this.data = data;
    }

    public Result(ResultCode resultCode, Object data) {
        this.code = resultCode.getCode();
        this.msg = resultCode.getMsg();
        this.data = data;
    }

    public static Result success(Object data) {
        return new Result(ResultCode.SUCCESS, data);
    }

    public static Result badParam(String msg) {
        return new Result(ResultCode.BAD_PARAM.getCode(), msg, null);
    }
}
